package com.SoilMM.service.impl;

import com.SoilMM.entity.RtimeMonitEntity;
import com.SoilMM.mapper.RtimeMonitMapper;
import com.SoilMM.service.RtimeMonitService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Gramorgan
 * @since 2021-06-23
 */
@Service
public class RtimeMonitServiceImpl extends ServiceImpl<RtimeMonitMapper, RtimeMonitEntity> implements RtimeMonitService {

    @Override
    public Map<String, Object> showRtimeParam(RtimeMonitEntity rtimeMonitEntity) {
        Map<String, Object> resultMap = new HashMap<>();
        // 1.获取控制器传来的分钟
        int minute = rtimeMonitEntity.getRtMinute();
        // 2.根据分钟查询数据库中的数据
        // QueryWrapper 查询对象， where xxx=?
        QueryWrapper<RtimeMonitEntity> wrapper = new QueryWrapper<>();
        wrapper.eq("rt_minute", minute);
        RtimeMonitEntity timeMonitEntity = baseMapper.selectOne(wrapper);
        // 3.判断结果
        if(null!=timeMonitEntity){
            resultMap.put("code",10000);
            resultMap.put("message","查询成功");
            resultMap.put("data", timeMonitEntity);
        }else {
            resultMap.put("code",10010);
            resultMap.put("message","可能由于网络原因，请刷新重试");
        }
        return resultMap;

    }
}
